Skip to content

Fallback to Host ID if WEBSITE_SITE_NAME isn't defined #1178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 28, 2025

Conversation

Charles-Gagnon
Copy link
Contributor

@Charles-Gagnon Charles-Gagnon commented May 6, 2025

Closes #1179

We got feedback that requiring WEBSITE_SITE_NAME wasn't very friendly to the local development experience, so instead of throwing an error we'll just fall back to the original hostIdProvider.GetHostIdAsync call.

This should be fine, since deployed functions should ALWAYS have a site name (set by the host environment) - and for local functions the only thing being lost is consumption scaling which doesn't apply anyways.

I decided to remove the setting from the samples, since generally we shouldn't expect people to need to define it anymore. And then I added a new test that does specifically set it to make sure that things still work as expected.

Copy link
Contributor

@MaddyDev MaddyDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@Charles-Gagnon Charles-Gagnon requested a review from Copilot May 9, 2025 23:13
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request implements a fallback mechanism for determining the function’s unique identifier by using the host ID when the WEBSITE_SITE_NAME configuration is not set, improving the local development experience. Key changes include:

  • Updating various methods and parameter names to reflect the new fallback strategy (e.g. renaming GetPrimaryKeyColumnsAsync to GetPrimaryKeyColumns, GetUserFunctionId to GetWebsiteSiteNameFunctionId, and GetOldUserFunctionIdAsync to GetHostIdFunctionIdAsync).
  • Adjusting SQL migration logic in the leases table creation to use the host ID where WEBSITE_SITE_NAME isn’t configured.
  • Removing the WEBSITE_SITE_NAME setting from the samples and updating documentation accordingly.

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/Integration/SqlTriggerBindingIntegrationTests.cs Added a new test to verify functionality when WEBSITE_SITE_NAME is defined.
src/TriggerBinding/SqlTriggerUtils.cs Renamed the method to better reflect its sync behavior.
src/TriggerBinding/SqlTriggerMetricsProvider.cs Updated the method call to use the refactored primary key logic.
src/TriggerBinding/SqlTriggerListener.cs Refactored parameter names and added migration logic for lease tables.
src/TriggerBinding/SqlTriggerBinding.cs Updated function ID resolution logic to use WEBSITE_SITE_NAME and host ID fallback.
src/SqlBindingUtilities.cs Removed the GetWebSiteName method to align with the new fallback approach.
samples/* Removed WEBSITE_SITE_NAME from local settings to simplify configuration.
docs/TriggerBinding.md & docs/BindingsOverview.md Updated documentation to explain the new fallback behavior.
Comments suppressed due to low confidence (1)

src/TriggerBinding/SqlTriggerListener.cs:413

  • Ensure that the migration logic using _hostIdFunctionId correctly covers all use cases when WEBSITE_SITE_NAME is not set, and verify that the fallback behavior aligns with intended function state management.
SELECT @lastSyncVersion = LastSyncVersion from az_func.GlobalState where UserFunctionID = '{this._hostIdFunctionId}' AND UserTableID = {userTableId}

@Charles-Gagnon Charles-Gagnon enabled auto-merge (squash) May 27, 2025 22:52
@Charles-Gagnon Charles-Gagnon merged commit dd8e853 into main May 28, 2025
2 checks passed
@Charles-Gagnon Charles-Gagnon deleted the chgagnon/fallbackHostId branch May 28, 2025 01:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove local function dependency of WEBSITE_SITE_NAME environment variable
4 participants